def setup
  size 500, 500, OPENGL
  @c = 0
  @tc = 0
  @m = Motion.new do |m|
    @c += (@tc - @c) * 0.1
    background @c, 0, 0
    m.stop if abs(@tc - @c) < 0.1
  end
end

def mousePressed
  @tc = 255
  @m.start
end

def mouseReleased
  @tc = 0
  @m.start
end